<?php
/**
 * Created by PhpStorm.
 * User: deng
 * Date: 2015/3/4
 * Time: 13:36
 */

use Think\Response;

function Decode($data)
{
    if (is_array($data)) {
        foreach ($data as $key => $value) {
            $data[$key] = Decode($value);
        }
        return $data;
    }
    return htmlspecialchars_decode($data);
}

function Success($code = '200', $data = '')
{
    Response::setHeader($code);
    Response::ajaxReturn(Decode($data));
}

function ClientError($message = null, $status = 200, $code = 0)
{
    throw new \Think\Exception($message, $status, $code);
}

function ServerError($message = null, $status = 500, $code = 0)
{
    throw new \Think\Exception($message, $status, $code);
}

